<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>借阅记录</title>
    <link href="../css/table.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="../js/table.js"></script>
</head>
<style type="text/css">
    @import url(../css/form.css);

    li {
        list-style: none;
    }

    .tdOne {
        text-align: right;
    }

    #biaoGe {
        width: 80%;
        margin: 0 auto;
        margin-top: 30px;
    }

    textarea.kuang {
        height: 300px;
        width: 600px;
    }
</style>
<body>
<h2>借阅记录列表</h2>

<table>
    <thead>
    <tr>
        根据读者编号查询:
        <form action="${basePath}record/recordByReader" method="post">
            <input type="text" name="readerId"/>
            <input type="submit" value="查询"/>
        </form>
    </tr>
    </thead>
    <tr>
        根据图书编号查询:
        <form action="${basePath}record/recordByBook" method="post">
            <input type="text" name="serialNumber"/>
            <input type="submit" value="查询"/>
        </form>
    </tr>

</table>

<%--根据读者编号查询:--%>
<%--<form action="${basePath}record/recordByReader" method="post">--%>
    <%--<input type="text" name="readerId"/>--%>
    <%--<input type="submit" value="查询"/>--%>
<%--</form>--%>

<%--根据图书编号查询:--%>
<%--<form action="${basePath}record/recordByBook" method="post">--%>
    <%--<input type="text" name="serialNumber"/>--%>
    <%--<input type="submit" value="查询"/>--%>
<%--</form>--%>

<form action="${basePath}record/getAllRecord" method="post">
    <input type="submit" value="所有记录"/>
</form>
<table>
    <thead>
    <tr>
        <th>读者编号</th>
        <th>读者姓名</th>
        <th>图书编号</th>
        <th>图书名</th>
        <th>借阅时间</th>
        <th>应归还时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="record" items="${recordList}">
        <input type="hidden" id="recordId" name="recordId" value="${record.id}"/>
        <input type="hidden" id="number" name="number"
               value="${record.book.amount}"/>
        <input type="hidden" id="bookId" name="bookId" value="${record.book.id}"/>
        <input type="hidden" id="readerId" name="readerId"
               value="${record.reader.id}"/>
        <tr>
            <td>${record.reader.id}</td>
            <td>${record.reader.name}</td>
            <td>${record.book.id}</td>
            <td>${record.book.name}</td>
            <td>${record.createTime1}</td>
            <td>${record.returnTime}</td>
            <c:choose>
                <c:when test="${record.isReturn ==1}">
                    <td><a href="${basePath}record/returnBook.action?recordId=${record.id}
                    &amount=${record.book.amount}&bookId=${record.book.id}">归还</a>
                        |<a href="${basePath}record/continueBook?recordId=${record.id}
                        &readerId=${record.reader.id}">续借</a></td>
                </c:when>
            </c:choose>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
<script type="text/javascript">
    function returnBook() {
        confirm('确认归还吗？');
        var recordId1 = document.getElementById("recordId").value;
        var number1 = document.getElementById("number").value;
        var bookId1 = document.getElementById("bookId").value;
        document.operationForm.action = "${basePath}/record/Record_returnBook.action?recordId="
        ${recordId}"&number=number1&bookId=bookId1";
        document.operationForm.submit();
    }
</script>
</html>
